# coding: utf8
"""
class重写Send IP：

"""
import psutil  # 获取网络信息的模块
import time
from os.path import exists, getsize
from os import mkdir, remove
from traceback import format_exc

# Local
import sys
sys.path.extend(['C:/Code/Py'])
from e_mail.send.cl_send_mail import SendMailAuto


class SendIp(SendMailAuto):
    """
    sendIP
    """
    def __init__(self, smtp_host, user, passwd, receives, subject, massage, *args, **kwargs):
        super().__init__(receives, subject, massage, smtp_host, user, passwd, *args, **kwargs)

    def get_ip(self):
        """
            获取网卡名称和其ip地址，不包括回环
            :return: dict {network_card: ip}
            """
        netCard_info = {}
        info = psutil.net_if_addrs()
        for k, v in info.items():  # 遍历所有网卡 - 包括 虚拟网卡；
            for item in v:  # 遍历网卡内信息；
                if item[0] == 2 and (not item[1] == '127.0.0.1'):  # 判断内容
                    print(k, '---', '*0*', item[0], '*1*', item[1])
                    netCard_info[k] = item[1]
        return netCard_info
